function BackfireLoadedCallback() {
    var url = "/umbraco/plugins/theoutfield/backfire4umbraco/backfire.aspx";

    function showBackfireBar() {
        var bar = document.getElementById('backfireBar');
        if (bar.className == '')
            bar.className = 'show';
    }

    function hideBackfireBar() {
        var bar = document.getElementById('backfireBar');
        if (bar.className == 'show')
            bar.className = '';
    }

    var backfireOptions =
    {
        url: url,
        verifyAccessOnLoad: true,
        messageHandler: function (message) {
            switch (message) {
                case "AccessGranted":
                    //if (window.console && window.console.firebug) 
                    if (navigator.userAgent.indexOf("Firefox") != -1) {
                        // add the css
                        var link = document.createElement('link');
                        link.href = "/umbraco/plugins/theoutfield/backfire4umbraco/backfire.css";
                        link.setAttribute('rel', 'stylesheet');
                        link.setAttribute('type', 'text/css');
                        link.setAttribute('media', 'screen');

                        // add the backfire bar
                        var div = document.createElement("div");
                        div.id = "backfireBar";

                        var button = document.createElement("a");
                        button.href = "#";
                        button.className = "button small";
                        button.innerHTML = "Save CSS changes";
                        button.onclick = function () { Backfire.save(); return false; }
                        div.appendChild(button);

                        window.setTimeout(function () {
                            document.getElementsByTagName('head')[0].appendChild(link);
                            document.body.appendChild(div);
                            showBackfireBar();

                        }, 1000);
                    }

                    break;
                case "AccessDenied":
                    //alert("Access denied.\n\nAre you signed in to Quplo?");
                    break;
                case "SaveSuccessful":
                    Backfire.refresh();
                    alert("Your changes have been saved.");
                    break;
                case "SaveFailed":
                    alert("The changes could not be saved.\n\nVisit http://our.umbraco.org/projects/developer-tools/backfire4umbraco to report this error.");
                    break;
            }
        }
    };
    Backfire.load(backfireOptions);
}

(function () {
    document.write("<script src=\"/umbraco/plugins/theoutfield/backfire4umbraco/backfire.js\"></script>");
})();